package jmine.tec.aom;

import bancosys.tec.exception.LocalizedMessageHolder;
import bancosys.tec.exception.MessageCreator;
import bancosys.tec.exception.MessageCreatorHelper;

/**
 * Defines the common error messages for the AOM component.
 * 
 * @author jrenaut
 */
public enum AOMMessages implements MessageCreator {
    INVALID_DOUBLE_FORMAT(2, "jmine.tec.aom.property.fill.invalidDoubleFormat"),

    INVALID_INTEGER_FORMAT(2, "jmine.tec.aom.property.fill.invalidIntegerFormat"),

    INVALID_DATE_FORMAT(2, "jmine.tec.aom.property.fill.invalidDateFormat"),

    INVALID_NUMBER_FORMAT(2, "jmine.tec.aom.property.fill.invalidNumberFormat"),

    INVALID_ENUM_VALUE(2, "jmine.tec.aom.property.fill.invalidEnumValue"),

    INVALID_PROPERTY_VALUE(3, "jmine.tec.aom.property.fill.invalidPropertyValue"),

    FIELD_REQUIRED(1, "jmine.tec.aom.property.service.field.required"),

    PROPERTY_NOT_FOUND(1, "jmine.tec.aom.property.not.found"),

    PROPERTY_NOT_FOUND_FOR_PROPERTIZED(2, "jmine.tec.aom.property.not.found.for.propertized"),

    MUST_BE_PROPERTIZED_AND_PERSISTABLE(1, "jmine.tec.aom.property.service.field.propertized"),

    PROPERTY_VALUE_CLASS_NOT_FOUND(2, "jmine.tec.aom.property.validation.class.not.found"),

    INVALID_PROPERTY_VALUE_CLASS(2, "jmine.tec.aom.property.validation.invalid.class");

    public static final String AOM_BUNDLE = "jmine-tec-aom-messages";

    private final MessageCreator delegate;

    /**
     * @param nargs the expected number of arguments for this message
     * @param key the key
     */
    private AOMMessages(int nargs, String key) {
        this(AOM_BUNDLE, key, nargs);
    }

    /**
     * @param bundle an i18n bundle
     * @param key the key
     * @param nargs the expected number of arguments for this message
     */
    private AOMMessages(String bundle, String key, int nargs) {
        this.delegate = MessageCreatorHelper.creator(bundle, key, nargs);
    }

    /**
     * {@inheritDoc}
     */
    public LocalizedMessageHolder create(Object... arguments) {
        return this.delegate.create(arguments);
    }

    /**
     * {@inheritDoc}
     */
    public int getExpectedArguments() {
        return this.delegate.getExpectedArguments();
    }

}
